package org.zfes.snowier.cloud.zbss.asf.router;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.zfes.snowier.core.util.ZAlert;
import org.zfes.snowier.core.util.ZAssert;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.common.file.FileResInfo;
import org.zfes.snowier.common.file.disk.UploadUitl;
@Controller 
@RequestMapping("/pub/face")
public class UploadController extends BaseController {

	
	@RequestMapping(value="/uploadImg", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public @ResponseBody  Object uploadImg(@RequestParam(name="file",required=false)MultipartFile file )  {
		ZAssert.notNull(file,"请选择文件");
		 try {
			 FileResInfo resInfo=UploadUitl.tranferFile( file, "sitz"); 
			 return ajaxQuery("fileUrl",resInfo.getFileUrl());
		 }catch (Exception e) {
			e.printStackTrace();
			ZAlert.Error("选择上传错误");
		}
		 return ajaxQuery("docPath", "");
	}
    

}